package cn.scw.framework.protocol;

import cn.scw.common.utils.ByteUtil;
import cn.scw.framework.protocol.tcp.ProtoDataHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * 解析器父类
 */
@Component
public class BaseDataResolver implements DataResolver {

    private static Logger logger= LoggerFactory.getLogger(ProtoDataHandler.class);

    @Override
    public String getResolverName() {
        return "base";
    }

    @Override
    public void resolveData(Integer type, byte[] orgData, ResolverContext resolverContext) {
        logger.info("type="+type);
        logger.info("orgData="+ ByteUtil.bytesToBinaryString(orgData));

        //发送回复
//        Channel channel=resolverContext.getChannelHandle().getChannel();
//        ByteBuf encoded = channel.alloc().buffer(4);//字节长度
//        encoded.writeBytes(ByteUtil.intToByteArray(0));//发送内容
//        channel.writeAndFlush(encoded);
    }

}
